package com.yoosora.controller;

import com.mikuac.shiro.common.utils.ShiroUtils;
import com.yoosora.utils.ImageUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.BufferedImageHttpMessageConverter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.awt.image.BufferedImage;
import java.io.IOException;

@RestController
public class ImageController {
	
	@Bean
	public BufferedImageHttpMessageConverter bufferedImageHttpMessageConverter() {
		return new BufferedImageHttpMessageConverter();
	}
	
	@GetMapping(value = "/satori",produces = "image/png")
	public BufferedImage satori(@RequestParam Long qq) throws IOException {
		BufferedImage img = null;
		img = ImageUtils.builder().satoriThrow(ShiroUtils.getUserAvatar(qq, 640)).build();
		return img;
	}
	
	
}

